/**
*  
* @Function TODO 
* @ProjectName credit-data-platform 
* @PackageName com.py.credit.controller    
* @FileName RemindReasonController.java    
* @Date 2018年5月11日下午6:24:06
* @Author Min DongXv
* @Copyright (c) 2018, 金电联行 All Rights Reserved.   
*   
*/
package com.py.credit.controller;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.entity.RemindReason;
import com.py.credit.service.RemindReasonService;
import com.py.framework.core.common.Page;

/**
 * 
 * @Function TODO
 * @ClassName RemindReasonController
 * @Date 2018年5月11日 下午6:24:06
 * @Author Min DongXv
 * 
 */
@RestController
@RequestMapping(value = "/remindReason")
public class RemindReasonController extends BaseController {

	@Autowired
	private RemindReasonService remindReasonService;

	/**
	 * 
	 * @api {get} /remindReason/getRemindReason.json 反馈列表
	 * @apiName getRemindReason
	 * @apiVersion 0.0.1
	 * @apiGroup 数据催收
	 * @apiParam {Integer} taskId 数据催收ID
	 * @apiParamExample {json} 请求参数示例 {"taskId":1}
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 * @apiSuccess {String} reason 反馈原因
	 * @apiSuccess {String} reasonDesc 反馈原因描述
	 * @apiSuccessExample {json} 成功返回结果
	 *                    {"code":0,"msg":null,"count":1,"data":[{"reason":"dfd","reasonDesc":"发多少"}]}
	 */
	@RequestMapping(value = "/getRemindReason.json")
	public RestServiceResult<List<Map<String, Object>>> getRemindReason(
			@RequestParam(value = "taskId", required = true) Integer taskId, Page page) {
		List<Map<String, Object>> data = remindReasonService.selectRemindReasonForPage(page, taskId);
		return new RestServiceResult<List<Map<String, Object>>>(page.getTotalCount(), data);
	}

	/**
	 * 
	 * @api {get} /addRemindReason/addRemindReason.json 新增反馈
	 * @apiName addRemindReason
	 * @apiVersion 0.0.1
	 * @apiGroup 数据催收
	 * @apiParam {Integer} taskId 数据催收ID
	 * @apiParam {String} reason 反馈原因
	 * @apiParam {String} reasonDesc 反馈原因描述
	 * @apiParamExample {json} 请求参数示例
	 *                  {"taskId":1,"reason":"原因","reasonDesc":"描述"}
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 */
	@RequestMapping(value = "/addRemindReason.json")
	public RestServiceResult<Object> addRemindReason(@RequestParam(value = "taskId", required = true) Integer taskId,
			@RequestParam(value = "reason", required = true) String reason,
			@RequestParam(value = "reasonDesc") String reasonDesc) {
		if (null != taskId && StringUtils.isNotBlank(reason)) {
			RemindReason remindReason = new RemindReason();
			remindReason.setMaintainer("1");
			remindReason.setReason(reason);
			remindReason.setTaskId(taskId);
			remindReason.setReasonDesc(reasonDesc);
			remindReasonService.addRemindReason(remindReason);
		}
		return new RestServiceResult<Object>();
	}
}
